package io.renren.modules.project.controller;

import java.util.Arrays;
import java.util.Map;
import java.util.List;

import io.renren.common.annotation.SysLog;
import io.renren.modules.project.entity.ProjectContractBillEntity;
import io.renren.modules.project.service.ProjectContractBillService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;


/**
 * 合同发票表
 *
 * @author ygg
 * @date 2021-05-25 17:30:42
 */
@RestController
@RequestMapping("project/contractbill")
public class ContractBillController {
    @Autowired
    private ProjectContractBillService projectContractBillService;

    /**
     * 分页查询
     */
    @RequestMapping("/page")
    public R page(@RequestParam Map<String, Object> params){
        PageUtils page = projectContractBillService.queryPage(params);

        return R.ok().put("page", page);
    }

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        List<ProjectContractBillEntity> list = projectContractBillService.queryList(params);

        return R.ok().put("list", list);
    }

    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Long id){
        ProjectContractBillEntity contractBill = projectContractBillService.selectById(id);

        return R.ok().put("contractBill", contractBill);
    }

    /**
     * 保存
     */
    @SysLog("保存发票")
    @RequestMapping("/save")
    @RequiresPermissions("project:contractbill:save")
    public R save(@RequestBody ProjectContractBillEntity projectContractBill){
		projectContractBillService.insert(projectContractBill);

        return R.ok();
    }

    /**
     * 修改
     */
    @SysLog("修改发票")
    @RequestMapping("/update")
    @RequiresPermissions("project:contractbill:update")
    public R update(@RequestBody ProjectContractBillEntity projectContractBill){
		projectContractBillService.updateAllColumnById(projectContractBill);

        return R.ok();
    }

    /**
     * 删除
     */
    @SysLog("删除发票")
    @RequestMapping("/delete")
    @RequiresPermissions("project:contractbill:delete")
    public R delete(@RequestBody Long[] ids){
		projectContractBillService.deleteBatch(ids);

        return R.ok();
    }

}
